﻿CREATE PROCEDURE [dbo].[proc_Finance_Bank_GetList]
	(
		@CompanyId int,
		@StartIndex int,
		@EndIndex int
	)
AS
begin
	
	;WITH list As(Select ROW_NUMBER() OVER (ORDER BY Id DESC)AS Row,
	Id,
	BId,
	TypeId,
	IsNull((Select Title From Finance_Bank_Type Where Id=Finance_Bank.TypeId),'...') As BankType,
	InitialMoney,
	CompanyId,
	IsNull((Select CompanyName From Company Where Id=Finance_Bank.CompanyId),'...') As Company,
	OpenBank,
	AccountName,
	AccountCartId,
	CreateDate,
	UserName
--	,
-- @XFL 20120106 Add Count_Sum --
--	(Select Count(Id) From Finance_Bank Where @CompanyId=0 Or CompanyId=@CompanyId) as Count_Sum
	From Finance_Bank Where (@CompanyId=0 Or CompanyId=@CompanyId)
	)
	Select *,(select count(0) from list)  as Count_Sum From list Where Row Between @StartIndex and @EndIndex
end
	RETURN
